using System;
using System.ComponentModel;
using Crm2011.Framework.Core;



namespace Crm2011.Framework.Connect
{
    public sealed class ConnectionProfile : INotifyPropertyChanged 
    {
        
        public Guid ConnectionId
        {
            get { return _connectionId; }	
            set
            {
                if(_connectionId == value) return;
                _connectionId = value;
                OnPropertyChanged("ConnectionId");
            }
        }
        private Guid _connectionId;


        
        public string ConnectionName
        {
            get { return _connectionName; }	
            set
            {
                if(_connectionName == value) return;
                _connectionName = value;
                OnPropertyChanged("ConnectionName");
            }
        }
        private string _connectionName;


        
        public string ConnectionString
        {
            get { return _connectionString; }	
            set
            {
                if(_connectionString == value) return;
                _connectionString = value;
                OnPropertyChanged("ConnectionString");
            }
        }
        private string _connectionString;


        public CrmConnectionString GetCrmConnectionString()
        {
            return !string.IsNullOrEmpty(this.ConnectionString) ? new CrmConnectionString(this.ConnectionString) : null;
        }
       
        
        public event PropertyChangedEventHandler PropertyChanged;



        private void OnPropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}